package cn.wps.moffice.foreigntemplate.dialog; import android.app.Activity; import android.app.LoaderManager; import android.content.Context; import android.content.DialogInterface; import android.content.Loader; import android.graphics.Bitmap; import android.os.Bundle; import android.support.v4.internal.view.SupportMenu; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AbsListView; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.ListAdapter; import android.widget.ListView; import android.widget.TextView; import cn.wps.moffice.OfficeApp; import cn.wps.moffice.common.beans.CommonErrorPage; import cn.wps.moffice.common.brand.BrandProgressBarCycle; import cn.wps.moffice.common.fontname.CircleProgressBar; import cn.wps.moffice.common.infoflow.internal.cards.template.RoundRectGifImageView; import cn.wps.moffice.common.multi.droplist.MultiButtonForHome; import cn.wps.moffice.foreigntemplate.bean.EnTemplateBean; import cn.wps.moffice.foreigntemplate.dialog.DashTemplateListDialog; import cn.wps.moffice.main.common.viewcontrols.ViewTitleBar; import cn.wps.moffice.templatecommon.ext.net.ExtOkDataModel; import cn.wps.moffice_eng.R; import com.fasterxml.jackson.core.util.MinimalPrettyPrinter; import com.google.gson.reflect.TypeToken; import defpackage.czq; import defpackage.dsa; import defpackage.fbo; import defpackage.fcj; import defpackage.vzh; import java.io.File; import java.util.ArrayList; import java.util.List; public class DashTemplateListDialog extends czq.a implements LoaderManager.LoaderCallbacks<ArrayList<EnTemplateBean>>, DialogInterface.OnDismissListener, View.OnClickListener, AbsListView.OnScrollListener, fbm { private static final int LOAD_ID = 4097; private static final int LOAD_ID_DOWNLOAD = 4098; private final int QUERY_COUNT = 20; private final Activity mActivity; private a mAdapter; private fbl mDataInterface; private CommonErrorPage mErrorPage; private fbn mGifDialog; private boolean mHasMoreData; private boolean mIsLoadingMore; private ListView mListView; private LoaderManager mLoader; private ViewGroup mLoadingFooterView; private BrandProgressBarCycle mProgressBar; private String mSortType = "vcount"; private View mSwitchOrderButton; private List<EnTemplateBean> mTemplateBeans; /* access modifiers changed from: package-private */ public static class a extends BaseAdapter { private View.OnClickListener cVN; private final List<EnTemplateBean> fzl; int fzm = -1; int fzn = -1; private final Context mContext; /* renamed from: cn.wps.moffice.foreigntemplate.dialog.DashTemplateListDialog$a$a reason: collision with other inner class name */ static class C0019a { View ebQ; ImageView fzr; TextView fzs; View fzt; TextView fzu; TextView fzv; View fzw; View fzx; RoundRectGifImageView fzy; CircleProgressBar fzz; View mView; private C0019a() { } /* synthetic */ C0019a(byte b) { this(); } } a(Context context, List<EnTemplateBean> list, View.OnClickListener onClickListener) { this.fzl = list; this.mContext = context; this.cVN = onClickListener; } /* access modifiers changed from: private */ /* renamed from: uH */ public EnTemplateBean getItem(int i) { return this.fzl.get(i); } public final int getCount() { return this.fzl.size(); } public final long getItemId(int i) { return 0; } public final int getItemViewType(int i) { EnTemplateBean uH = getItem(i); return (uH == null || "16:9".equals(uH.ppt_ratio) || !"4:3".equals(uH.ppt_ratio)) ? 0 : 1; } public final View getView(int i, View view, ViewGroup viewGroup) { final C0019a aVar; if (view == null) { C0019a aVar2 = new C0019a((byte) 0); Context context = this.mContext; if (getItemViewType(i) == 0) { aVar2.mView = View.inflate(context, R.layout.foreign_bling_list_item_16_9_layout, null); } else { aVar2.mView = View.inflate(context, R.layout.foreign_bling_list_item_4_3_layout, null); } aVar2.fzr = (ImageView) aVar2.mView.findViewById(R.id.iv_cover); aVar2.fzs = (TextView) aVar2.mView.findViewById(R.id.tv_duration); aVar2.fzt = aVar2.mView.findViewById(R.id.iv_play); aVar2.fzu = (TextView) aVar2.mView.findViewById(R.id.tv_title); aVar2.fzv = (TextView) aVar2.mView.findViewById(R.id.tv_insert); aVar2.ebQ = aVar2.mView.findViewById(R.id.image_layout); aVar2.fzw = aVar2.mView.findViewById(R.id.gif_layout); aVar2.fzy = (RoundRectGifImageView) aVar2.mView.findViewById(R.id.gif_image); aVar2.fzz = (CircleProgressBar) aVar2.mView.findViewById(R.id.progress); aVar2.fzx = aVar2.mView.findViewById(R.id.load_fail_layout); aVar = aVar2; } else { aVar = (C0019a) view.getTag(); } Context context2 = this.mContext; EnTemplateBean uH = getItem(i); View.OnClickListener onClickListener = this.cVN; aVar.fzu.setText(uH.name); aVar.fzs.setText(uH.ppt_animation_time + "s"); String e = fcj.e(uH.file_prefix, uH.cover_image, fcj.a.fBR); if (!TextUtils.isEmpty(e)) { vzh.a fVo = vzh.m252if(context2).fVo(); fVo.mTag = "template_online_activity"; fVo.cvP = e; vzh.b fVp = fVo.fVp(); fVp.wEB = R.drawable.internal_template_default_item_bg; fVp.wcC = context2.getResources().getColor(R.color.retain_dialog_bg); fVp.dYN = ImageView.ScaleType.FIT_XY; fVp.a(aVar.fzr); } else { aVar.fzr.setImageResource(R.drawable.internal_template_default_item_bg); } aVar.fzv.setTag(uH); aVar.fzv.setOnClickListener(onClickListener); aVar.ebQ.setTag(Integer.valueOf(i)); aVar.ebQ.setOnClickListener(onClickListener); aVar.fzw.setTag(uH.file_prefix + uH.gif_image_url); aVar.fzw.setOnClickListener(onClickListener); aVar.fzx.setTag(Integer.valueOf(i)); aVar.fzx.setOnClickListener(onClickListener); aVar.fzr.setVisibility(0); if (this.fzm != i || TextUtils.isEmpty(getItem(i).gif_image_url)) { aVar.ebQ.setVisibility(0); aVar.fzw.setVisibility(8); aVar.fzx.setVisibility(8); } else { aVar.ebQ.setVisibility(8); aVar.fzw.setVisibility(0); aVar.fzx.setVisibility(8); aVar.fzz.setProgress(0.0f); aVar.fzz.setIndeterminate(false); aVar.fzz.setVisibility(8); final String str = getItem(i).file_prefix + getItem(i).gif_image_url; aVar.fzy.setRadius(10.0f); DashTemplateListDialog.loadGif(this.mContext, aVar.fzy, str, new b() { /* class cn.wps.moffice.foreigntemplate.dialog.DashTemplateListDialog.a.AnonymousClass1 */ @Override // cn.wps.moffice.foreigntemplate.dialog.DashTemplateListDialog.b public final void aLa() { aVar.fzz.setVisibility(8); aVar.fzr.setVisibility(8); } @Override // cn.wps.moffice.foreigntemplate.dialog.DashTemplateListDialog.b public final void bto() { File ll = dry.bt(a.this.mContext).ll(str); if (ll == null || !ll.exists()) { aVar.fzz.setVisibility(0); } } @Override // cn.wps.moffice.foreigntemplate.dialog.DashTemplateListDialog.b public final void onError() { fcz.b(new Runnable() { /* class cn.wps.moffice.foreigntemplate.dialog.DashTemplateListDialog.a.AnonymousClass1.AnonymousClass2 */ public final void run() { aVar.fzz.setVisibility(8); a.this.fzm = -1; aVar.fzw.setVisibility(8); aVar.ebQ.setVisibility(8); aVar.fzx.setVisibility(0); } }, false); } @Override // cn.wps.moffice.foreigntemplate.dialog.DashTemplateListDialog.b public final void uJ(final int i) { fcz.b(new Runnable() { /* class cn.wps.moffice.foreigntemplate.dialog.DashTemplateListDialog.a.AnonymousClass1.AnonymousClass1 */ public final void run() { if (aVar.fzz.getVisibility() != 0) { aVar.fzz.setVisibility(0); } aVar.fzz.setProgress((float) i); } }, false); } }); } aVar.mView.setTag(aVar); return aVar.mView; } } public interface b { void aLa(); void bto(); void onError(); void uJ(int i); } public DashTemplateListDialog(Activity activity) { super(activity, R.style.Dialog_Fullscreen_StatusBar_push_animations); setOnDismissListener(this); this.mActivity = activity; } private List<EnTemplateBean> getTemplateBeans() { if (this.mTemplateBeans == null) { this.mTemplateBeans = new ArrayList(); } return this.mTemplateBeans; } /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void loadData() { if (this.mLoader == null) { this.mLoader = this.mActivity.getLoaderManager(); } this.mLoader.restartLoader(4097, null, this); } public static void loadGif(final Context context, final RoundRectGifImageView roundRectGifImageView, final String str, final b bVar) { if (bVar != null) { bVar.bto(); } File ll = dry.bt(context).ll(str); if (roundRectGifImageView.edu || (ll != null && ll.exists())) { dsa li = dry.bt(context).li(str); li.dYL = false; li.dYN = ImageView.ScaleType.FIT_CENTER; li.a(new ImageView(context), new dsa.b() { /* class cn.wps.moffice.foreigntemplate.dialog.DashTemplateListDialog.AnonymousClass6 */ @Override // defpackage.dsa.b public final void a(ImageView imageView, Bitmap bitmap) { roundRectGifImageView.post(new Runnable() { /* class cn.wps.moffice.foreigntemplate.dialog.DashTemplateListDialog.AnonymousClass6.AnonymousClass1 */ public final void run() { if (bVar != null) { bVar.aLa(); } DashTemplateListDialog.updateGifImage(roundRectGifImageView, str); } }); } @Override // defpackage.dsa.b public final void co(int i, int i2) { int i3 = i2 / i; if (bVar != null) { bVar.uJ(i3); } } @Override // defpackage.dsa.b public final void onError() { if (bVar != null) { bVar.onError(); } } }); } else if (!roundRectGifImageView.edu) { dsa li2 = dry.bt(context).li(str); li2.dYL = false; li2.dYN = ImageView.ScaleType.FIT_CENTER; li2.a(new ImageView(context), new dsa.b() { /* class cn.wps.moffice.foreigntemplate.dialog.DashTemplateListDialog.AnonymousClass7 */ @Override // defpackage.dsa.b public final void a(ImageView imageView, Bitmap bitmap) { roundRectGifImageView.setDrawRectChanged(true); dtt.a(imageView, bitmap, 3); DashTemplateListDialog.loadGif(context, roundRectGifImageView, str, bVar); } @Override // defpackage.dsa.b public final void co(int i, int i2) { int i3 = (i2 * 100) / i; if (bVar != null) { bVar.uJ(i3); } } @Override // defpackage.dsa.b public final void onError() { if (bVar != null) { bVar.onError(); } } }); } } private void setHasMoreLoadingView() { this.mLoadingFooterView.setVisibility(this.mHasMoreData ? 0 : 4); } /* access modifiers changed from: private */ public static void updateGifImage(RoundRectGifImageView roundRectGifImageView, String str) { try { roundRectGifImageView.setDrawRectChanged(true); abow hgK = ((abox) new abox().bK(dry.bt(OfficeApp.arx().getApplicationContext()).ll(str))).hgK(); hgK.apJ(SupportMenu.USER_MASK); hgK.start(); roundRectGifImageView.setImageDrawable(hgK); } catch (Exception e) { e.printStackTrace(); } } public void initView(View view) { this.mListView = (ListView) view.findViewById(R.id.lv_container); this.mSwitchOrderButton = view.findViewById(R.id.tv_switch); this.mProgressBar = (BrandProgressBarCycle) view.findViewById(R.id.progress_bar); this.mErrorPage = (CommonErrorPage) view.findViewById(R.id.error_page); this.mErrorPage.setTitleBottomHeight(((int) luf.bx(this.mActivity)) + luf.D(this.mActivity, R.id.title_bar_area)); this.mErrorPage.a(new View.OnClickListener() { /* class cn.wps.moffice.foreigntemplate.dialog.DashTemplateListDialog.AnonymousClass3 */ public final void onClick(View view) { DashTemplateListDialog.this.loading(true); DashTemplateListDialog.this.loadData(); } }); this.mAdapter = new a(this.mActivity, getTemplateBeans(), this); this.mListView.setAdapter((ListAdapter) this.mAdapter); this.mLoadingFooterView = (ViewGroup) LayoutInflater.from(this.mActivity).inflate(R.layout.listview_loading_view, (ViewGroup) this.mListView, false); this.mListView.addFooterView(this.mLoadingFooterView); this.mListView.setOnScrollListener(this); this.mLoadingFooterView.setVisibility(4); this.mSwitchOrderButton.setOnClickListener(this); loadData(); loading(true); } @Override // defpackage.fbm public void loading(boolean z) { if (z) { this.mProgressBar.setVisibility(0); } else { this.mProgressBar.setVisibility(8); } } public void onClick(View view) { File ll; switch (view.getId()) { case R.id.gif_layout /*{ENCODED_INT: 2131364014}*/: if (view.getTag() != null) { String str = (String) view.getTag(); if (!TextUtils.isEmpty(str) && (ll = dry.bt(this.mActivity).ll(str)) != null && ll.exists()) { showGifDialog(str); this.mAdapter.fzn = this.mAdapter.fzm; this.mAdapter.fzm = -1; this.mAdapter.notifyDataSetChanged(); return; } return; } return; case R.id.image_layout /*{ENCODED_INT: 2131364595}*/: this.mAdapter.fzm = ((Integer) view.getTag()).intValue(); this.mAdapter.notifyDataSetChanged(); return; case R.id.load_fail_layout /*{ENCODED_INT: 2131364975}*/: view.setVisibility(8); this.mAdapter.fzm = ((Integer) view.getTag()).intValue(); this.mAdapter.notifyDataSetChanged(); return; case R.id.tv_insert /*{ENCODED_INT: 2131368797}*/: if (view.getTag() != null && (view.getTag() instanceof EnTemplateBean)) { EnTemplateBean enTemplateBean = (EnTemplateBean) view.getTag(); dwp.at("public_ppt_edit_insertbling_click", enTemplateBean.id); LoaderManager loaderManager = this.mLoader; Activity activity = this.mActivity; AnonymousClass4 r6 = new fbo.b() { /* class cn.wps.moffice.foreigntemplate.dialog.DashTemplateListDialog.AnonymousClass4 */ @Override // defpackage.fbo.b public final void btn() { fcz.b(new Runnable() { /* class cn.wps.moffice.foreigntemplate.dialog.DashTemplateListDialog.AnonymousClass4.AnonymousClass3 */ public final void run() { lvg.d(OfficeApp.arx(), R.string.notice_download_failed, 0); DashTemplateListDialog.this.loading(false); } }, false); } @Override // defpackage.fbo.b public final void onStart() { fcz.b(new Runnable() { /* class cn.wps.moffice.foreigntemplate.dialog.DashTemplateListDialog.AnonymousClass4.AnonymousClass1 */ public final void run() { DashTemplateListDialog.this.loading(true); } }, false); } @Override // defpackage.fbo.b public final void onSuccess() { fcz.b(new Runnable() { /* class cn.wps.moffice.foreigntemplate.dialog.DashTemplateListDialog.AnonymousClass4.AnonymousClass2 */ public final void run() { DashTemplateListDialog.this.loading(false); } }, false); } }; if (activity != null && !activity.isFinishing() && enTemplateBean != null && loaderManager != null) { if (!ebo.arU()) { fpp.rX("2"); } ebo.b(activity, new Runnable(enTemplateBean, activity, this, loaderManager, 4098, r6) { /* class defpackage.fbo.AnonymousClass1 */ final /* synthetic */ EnTemplateBean fyg; final /* synthetic */ DashTemplateListDialog fzA; final /* synthetic */ LoaderManager fzB; final /* synthetic */ int fzC; final /* synthetic */ b fzD; final /* synthetic */ Activity val$activity; { this.fyg = r1; this.val$activity = r2; this.fzA = r3; this.fzB = r4; this.fzC = r5; this.fzD = r6; } public final void run() { EnTemplateBean enTemplateBean = this.fyg; if (fcc.z(enTemplateBean.id, enTemplateBean.name, enTemplateBean.format)) { fbo.a(this.val$activity, this.fzA, this.fyg); } else { this.fzB.restartLoader(this.fzC, null, new a(this.val$activity, this.fzA, this.fyg, this.fzD)); } } }); return; } return; } return; case R.id.tv_switch /*{ENCODED_INT: 2131368829}*/: if ("vcount".equals(this.mSortType)) { this.mSortType = "mtime"; } else { this.mSortType = "vcount"; } getTemplateBeans().clear(); loadData(); loading(true); return; default: return; } } /* access modifiers changed from: protected */ public void onCreate(Bundle bundle) { View inflate = View.inflate(getContext(), R.layout.fragment_foreign_bling_template_list_layout, null); ViewTitleBar viewTitleBar = (ViewTitleBar) inflate.findViewById(R.id.title_bar_area); viewTitleBar.setGrayStyle(getWindow()); Activity activity = this.mActivity; gsc.f(inflate.findViewById(R.id.title_bar_area), false); setContentView(inflate); viewTitleBar.setTitleText(eix.UILanguage_chinese == eip.eSn ? this.mActivity.getString(R.string.quick_flash_templates) : this.mActivity.getString(R.string.quick_flash) + MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR + this.mActivity.getString(R.string.name_templates)); viewTitleBar.gBO.setOnClickListener(new View.OnClickListener() { /* class cn.wps.moffice.foreigntemplate.dialog.DashTemplateListDialog.AnonymousClass1 */ public final void onClick(View view) { DashTemplateListDialog.this.dismiss(); } }); viewTitleBar.setIsNeedMultiDocBtn(false); viewTitleBar.gBP.setMultiButtonForHomeCallback(new MultiButtonForHome.a() { /* class cn.wps.moffice.foreigntemplate.dialog.DashTemplateListDialog.AnonymousClass2 */ @Override // cn.wps.moffice.common.multi.droplist.MultiButtonForHome.a public final boolean auh() { return false; } }); initView(inflate); } @Override // android.app.LoaderManager.LoaderCallbacks public Loader<ArrayList<EnTemplateBean>> onCreateLoader(int i, Bundle bundle) { String str = null; if (this.mDataInterface != null) { str = this.mDataInterface.btm(); } fbv btv = fbv.btv(); Activity activity = this.mActivity; String str2 = this.mSortType; int size = getTemplateBeans().size(); hwe hwe = new hwe(); hwe.dk("sort_field", str2); if (!TextUtils.isEmpty(str)) { hwe.dk("ppt_ratio", str); } hwe.dk("start", String.valueOf(size)); hwe.dk("limit", "20"); fbv.a(activity, hwe, true); return new lof(activity).Lr(0).HX("http://api.docer.4wps.net/index/fastflash").b(new TypeToken<ArrayList<EnTemplateBean>>() { /* class defpackage.fbv.AnonymousClass11 */ }.getType()).u(hwe.cmr()); } public void onDismiss(DialogInterface dialogInterface) { this.mLoader.destroyLoader(4097); this.mLoader.destroyLoader(4098); } public void onLoadFinished(Loader<ArrayList<EnTemplateBean>> loader, ArrayList<EnTemplateBean> arrayList) { boolean z = false; if (!this.mIsLoadingMore) { loading(false); } else { this.mIsLoadingMore = false; } if (arrayList != null && arrayList.size() > 0) { this.mErrorPage.setVisibility(8); getTemplateBeans().addAll(arrayList); this.mAdapter.notifyDataSetChanged(); if (arrayList.size() >= 20) { z = true; } this.mHasMoreData = z; } else if (getTemplateBeans().size() <= 0) { this.mErrorPage.setVisibility(0); if (!(loader instanceof lof) || !ExtOkDataModel.isSupportedOkData(((lof) loader).ohq)) { this.mErrorPage.nR(R.string.documentmanager_cloudfile_no_network); this.mErrorPage.nT(R.drawable.phone_public_no_network_icon); this.mErrorPage.nS(R.string.ppt_retry); } else { this.mErrorPage.nR(R.string.public_no_recovery_file_record); this.mErrorPage.nT(R.drawable.public_template_none_error_icon); this.mErrorPage.cNF.setVisibility(8); } } setHasMoreLoadingView(); } @Override // android.app.LoaderManager.LoaderCallbacks public void onLoaderReset(Loader<ArrayList<EnTemplateBean>> loader) { } public void onScroll(AbsListView absListView, int i, int i2, int i3) { if (!this.mIsLoadingMore && i + i2 >= i3 && getTemplateBeans().size() != 0 && this.mHasMoreData) { this.mIsLoadingMore = true; loadData(); } if (this.mAdapter.fzm < i || this.mAdapter.fzm > i + i2) { this.mAdapter.fzm = -1; } } public void onScrollStateChanged(AbsListView absListView, int i) { } public void onTemplateDownloadFinish(String str) { if (this.mDataInterface != null) { this.mDataInterface.onTemplateDownloadFinish(str); } } @Override // defpackage.fbm public void setDataInterface(fbl fbl) { if (fbl != null) { this.mDataInterface = fbl; } } public void showGifDialog(String str) { if (this.mGifDialog == null) { this.mGifDialog = new fbn(this.mActivity); } fbn fbn = this.mGifDialog; fbn.url = str; fbn.show(); this.mGifDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { /* class cn.wps.moffice.foreigntemplate.dialog.DashTemplateListDialog.AnonymousClass5 */ public final void onDismiss(DialogInterface dialogInterface) { if (DashTemplateListDialog.this.mActivity != null && !DashTemplateListDialog.this.mActivity.isFinishing() && DashTemplateListDialog.this.isShowing()) { DashTemplateListDialog.this.mAdapter.fzm = DashTemplateListDialog.this.mAdapter.fzn; DashTemplateListDialog.this.mAdapter.notifyDataSetChanged(); } } }); } }